Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

313
Visualizações
Nightwatch JS | Getting Next Sibling Text

I am attempting to write a function that can acquire the text value of a nextSibling node underneath a label bracket. I need to be able to put that text into a global variable that I can reference later in the test, but my current function, while it is retrieving the webElementId, is not retrieving the text. Instead, my console.log function is outputting a blank value.

To give some context on the code in question, here is the HTML layout of the field I am attempting to parse.

<iframe> id=[some_id]
  #document
    <html>
      <head>
        <body>
          <div> id=[some_id]
            <form> id=[some_id]
              <div> id=[some_id]
                <div> id=[some_id]
                  <div> style=[some_style]
                    <label>[some text]<label>
                      [text field in question]

That's just the basic layout, but here is the code snippet that I am attempting to use to grab the sibling node, get the id, and then get the text of the webElementId.

.getNextSibling('div[id=popover_content] > form[id=perform_sub_task_form] > div[id=perform_task] > div[id=dialog_container] > div > label:nth-of-type(8)', function(dateObj) {
  let dateVal = dateObj.value.getId()
    console.log(`datevalue: ${dateVal}`)
    browser.elementIdText(`${dateVal}`, function(result) {
      console.log('\n' + result.value)
      initial_date = result.value
})
 })

I have already attempted to simplify this and run a callback function on just the .getNextSibling function using result.value.getText(), that just results in Nightwatch telling me that the function doesn't exist. Reading the documentation for the getNextSibling() function, I found that getId() can be added onto the callback, so I decided to use that to my advantage and attempt to use the provided webElementId and write the snippet above.

I know that my code works up to the first console.lg function, because the webElementId is successfully rendered in the terminal I'm running off of. But once it tries to log the result.value, a blank line appears in the terminal.

My question is, how can I edit this snippet above so that it stops giving me a blank value? Is there an issue with my browser.elementIdText() function?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda